Skip to content

Chore: refactor Comparison out of QueryPlanSerde #2028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

CuteChuanChuan
Copy link

@CuteChuanChuan CuteChuanChuan commented Jul 15, 2025

Which issue does this PR close?
Part of #2019

Rationale for this change
See #2019 for rationale.

What changes are included in this PR?
Moved comparison expressions to separate file (comparison.scala)

How are these changes tested?
There are no functional changes, so it relies on existing tests.

Details:

  • Add ComparisonBase trait with reusable helper methods
  • Move GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual to CometComparison*
  • Move IsNull, IsNotNull, IsNaN to CometIs* classes
  • Move In expression to CometIn class
  • Update exprSerdeMap to use new comparison classes
  • Remove corresponding case statements from exprToProtoInternal

- Create comparisons.scala following the pattern from math/array expressions.
- Implements CometGreaterThan as proof of concept for issue apache#2019.
@CuteChuanChuan CuteChuanChuan force-pushed the raymond/refactor-expressions-in-QueryPlanSerde branch from 56ddd51 to 202556d Compare July 17, 2025 15:03
- Add ComparisonBase trait with reusable helper methods
- Move GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual to CometComparison*
- Move IsNull, IsNotNull, IsNaN to CometIs* classes
- Move In expression to CometIn class
- Update exprSerdeMap to use new comparison classes
- Remove corresponding case statements from exprToProtoInternal
@CuteChuanChuan CuteChuanChuan changed the title [WIP] chore: refactor Comparison out of QueryPlanSerde Chore: refactor Comparison out of QueryPlanSerde Jul 17, 2025
@CuteChuanChuan CuteChuanChuan marked this pull request as ready for review July 17, 2025 15:16
@codecov-commenter
Copy link

codecov-commenter commented Jul 18, 2025

Codecov Report

Attention: Patch coverage is 90.00000% with 11 lines in your changes missing coverage. Please review.

Project coverage is 58.77%. Comparing base (f09f8af) to head (2606d4f).
Report is 331 commits behind head on main.

Files with missing lines Patch % Lines
...ain/scala/org/apache/comet/serde/comparisons.scala 89.10% 7 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2028      +/-   ##
============================================
+ Coverage     56.12%   58.77%   +2.64%     
- Complexity      976     1253     +277     
============================================
  Files           119      135      +16     
  Lines         11743    13159    +1416     
  Branches       2251     2392     +141     
============================================
+ Hits           6591     7734    +1143     
- Misses         4012     4186     +174     
- Partials       1140     1239      +99     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CuteChuanChuan
Copy link
Author

Hi @andygrove ,

Could you please take a look at this PR and provide some guidance when you have a chance? I've refactored the comparison expressions (GreaterThan, LessThan, IsNull, In, etc.) following the pattern discussed in #2019.

In the meantime, I'll continue working on refactoring the remaining expressions from the list.

Thanks!

@mbutrovich mbutrovich self-requested a review July 23, 2025 14:19
Copy link
Contributor

@mbutrovich mbutrovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the first contribution @CuteChuanChuan. First feedback provided below.

* @return
* Some(Expr) or None if not supported
*/
def createUnaryExpr(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we duplicate createUnaryExpr and createBinaryExpr here?

}
}

def in(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only called in one location. Can we move this logic to the call site in CometIn since it seems specific to that expression?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants